<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
	</head>
	<body>
		
		<h1 align="center" id="EV"></h1>
		
		<script type="text/javascript">
			let marketPrice={
				egg:0,
				Potion:0,
				Yellow:0,
				Purple:0,
				Metamon:0,
				Rmetamon:0,
				sRmetamon:0,
				ssRmetamon:0
				
			}
			const url='https://market-api.radiocaca.com/nft-sales?pageNo=1&pageSize=1&sortBy=fixed_price&'
			//获取蛋的价格
			axios.get(url+'order=asc&name=&saleType&category=17&tokenType')
			  .then(function (response) {
			    marketPrice.egg=Number(response.data.list[0].fixed_price);
			//获取药水价格
			return axios.get(url+'order=asc&name=&saleType&category=15&tokenType')
			  })
			  .then(function(response){
				  marketPrice.Potion=Number(response.data.list[0].fixed_price);
			//获取黄钻价格
			return axios.get(url+'order=asc&name=&saleType&category=16&tokenType')
			  })
			  .then(function(response){
				  marketPrice.Yellow=Number(response.data.list[0].fixed_price);
			//获取紫钻价格
			return axios.get(url+'name=Purple%20Diamond&order=asc&saleType&category=16&tokenType')
			  })
			  .then(function(response){
				  marketPrice.Purple=Number(response.data.list[0].fixed_price);
		    //获取元兽价格
			return axios.get(url+'order=asc&name=&saleType&category=13&tokenType')
			  })
			  .then(function(response){
				  marketPrice.Metamon=Number(response.data.list[0].fixed_price);
			//获取R元兽价格
			return axios.get(`https://www.radiocaca.cn/bake?t=${new Date().getTime()}`)
			  })
			  .then(function(response){
				  response.data.raca_list.forEach(function(item){
					  if(item.name=='R元兽'){
						  marketPrice.Rmetamon=item.list[0].price
					  }
					  if(item.name=='SR元兽'){
					  	 marketPrice.sRmetamon=item.list[0].price
					  }
					  if(item.name=='特斯拉[Tesla RACA]'){
						  marketPrice.ssRmetamon=item.list[0].price
					  }
				  })
				   console.log(marketPrice)
				   //判断EV
				   let obj={}
				   for(let v in marketPrice){
					   if(v=='Potion'){
						   obj[v]=(marketPrice[v]*2-marketPrice.egg)*0.7
					   }
					   if(v=='Yellow'){
					   	   obj[v]=(marketPrice[v]-marketPrice.egg)*0.12
					   }
					   if(v=='Purple'){
					   	   obj[v]=(marketPrice[v]-marketPrice.egg)*0.0012
					   }
					   if(v=='Metamon'){
					   	   obj[v]=((marketPrice[v]-marketPrice.egg)+(marketPrice.Metamon/3))*0.176
					   }
					   if(v=='Rmetamon'){
					   	   obj[v]=(marketPrice[v]-marketPrice.egg)*0.00183
					   }
					   if(v=='sRmetamon'){
					   	   obj[v]=(marketPrice[v]-marketPrice.egg)*0.000015
					   }
					   if(v=='ssRmetamon'){
					   	   obj[v]=(marketPrice[v]-marketPrice.egg)* 0.00000242
					   }
				   }
				   console.log(obj)
				   let sum=0
				   for(v in obj){
					   sum+=obj[v]
				   }
				   document.querySelector("#EV").innerHTML=sum.toFixed(2)
			  })
				
		</script>
	</body>
</html>
